#include <iostream> 
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <fstream>
using namespace std;

#include "bgacomlib.h"
#include <crtdbg.h>
#include <tchar.h>
//#include "../../../../sqa/serial/serial/serial.h"
using namespace BogozmaCommunicationLibrary;

// Declaration of all boolean variables

bool testConstructor1;
bool testConstructor2;

bool testDiscoverDevices1;

bool testGetNumberofDevices1;
bool testGetNumberofDevices2;

bool testGetDevice1;
bool testGetDevice2;

bool testGetDevicebyName1;
bool testGetDevicebyName2;
bool testGetDevicebyName3;
bool testGetDevicebyName4;

bool testGetDevicebyIp1;
bool testGetDevicebyIp2;
bool testGetDevicebyIp3;

bool testGetDevicebyMac1;
bool testGetDevicebyMac2;
bool testGetDevicebyMac3;
bool testGetDevicebyMac4;
bool testGetDevicebyMac5;
bool testGetDevicebyMac6;

CBgaNetSystem* my_system;
CBgaLinkoo* my_linkoo;

///////////////////////////////////////////////////////////
////////////////////// SET UP /////////////////////////////
///////////////////////////////////////////////////////////

void setUp()
{
/*	my_system = NULL;
	my_linkoo = NULL;
	my_system = new CBgaNetSystem(eAny);
	my_linkoo = (CBgaLinkoo*)my_system->GetDevice(0);*/
}

///////////////////////////////////////////////////////////
////////////////////// SET UP /////////////////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
///////////////////// TEAR DOWN ///////////////////////////
///////////////////////////////////////////////////////////

void tearDown()
{  
/*	if(my_system != NULL)
    {
		delete my_system;
		my_system = NULL;
    }

	my_linkoo = NULL;*/
}

///////////////////////////////////////////////////////////
///////////////////// TEAR DOWN ///////////////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
////////////////// TEST CONSTRUCTORS //////////////////////
///////////////////////////////////////////////////////////

void testConstructors()
{
   //Set up
   CBgaNetSystem AutoSys(eAny);
   CBgaNetSystem NonAutoSys;
   CBgaDevice *pAutoDevice = NULL;
   CBgaDevice *pNonAutoDevice = NULL;

   //Process
   pAutoDevice = AutoSys.GetDevice(0);
   pNonAutoDevice = NonAutoSys.GetDevice(0);

   //Check
   if (pAutoDevice != NULL)
   {
	   testConstructor1 = true;
   }
   else
   {
	   testConstructor1 = false;
   }

   if (pNonAutoDevice == NULL)
   {	   
		testConstructor2 = true;
   }
   else
   {
		testConstructor2 = false;
   }
   //CPPUNIT_ASSERT(pAutoDevice != NULL);
   //CPPUNIT_ASSERT(pNonAutoDevice == NULL);
}

///////////////////////////////////////////////////////////
////////////////// TEST CONSTRUCTORS //////////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
///////////////// TEST DISCOVER DEVICES ///////////////////
///////////////////////////////////////////////////////////

void testDiscoverDevices()
{
   //Set up
   CBgaNetSystem NonAutoSys;
   CBgaDevice *pNonAutoDevice = NULL;

   //Process
   NonAutoSys.DiscoverDevices(eAny);
   pNonAutoDevice = NonAutoSys.GetDevice(0);

   //Check
   if (pNonAutoDevice != NULL)
   {
	   testDiscoverDevices1 = true;
   }
   else
   {
	   testDiscoverDevices1 = false;
   }
	   
   
   //CPPUNIT_ASSERT(pNonAutoDevice != NULL);
}

///////////////////////////////////////////////////////////
///////////////// TEST DISCOVER DEVICES  //////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
//////////////// TEST GET NUMBER OF DEVICES  //////////////
///////////////////////////////////////////////////////////

void testGetNumberOfDevices()
{
	//Set up
	CBgaNetSystem AutoSys(eAny); // when given an argument, the constructor calls a discovery
	CBgaNetSystem NonAutoSys;  // no discovery is made (empty constructor)
	CBgaDevice *pAutoDevice = NULL;
	CBgaDevice *pNonAutoDevice = NULL;

	//Process
	int DeviceCountOne = AutoSys.GetNumberOfDevices(eAny);
	int DeviceCountZero = NonAutoSys.GetNumberOfDevices(eAny);

	//Check
	if(DeviceCountOne == 1)
	{
		testGetNumberofDevices1 = true;
	}
	else
	{
		testGetNumberofDevices1 = false;
	}

	if(DeviceCountZero == 0)
	{
		testGetNumberofDevices2 = true;
	}

	else
	{
		testGetNumberofDevices2 = false;
	}


  // CPPUNIT_ASSERT(DeviceCountOne == 1);
  // CPPUNIT_ASSERT(DeviceCountZero == 0);
}

///////////////////////////////////////////////////////////
//////////////// TEST GET NUMBER OF DEVICES  //////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
//////////////////// TEST GET DEVICE  /////////////////////
///////////////////////////////////////////////////////////

void testGetDevice()
{
   //Set up
   CBgaNetSystem testSystem(eAny);
   CBgaDevice* myDevicePtrSuccessful = NULL; // check a case of a successful find
   CBgaDevice* myDevicePtrFail = (CBgaDevice*)0x69696969; // check an example of an unsuccessful Get

   //Process
   myDevicePtrSuccessful = testSystem.GetDevice(0); // works only on Jerry's Bouboule
   myDevicePtrFail = testSystem.GetDevice(1);

   //Check
   
   if (myDevicePtrSuccessful != NULL)
   {
	   testGetDevice1 = true;
   }
   else
   {
	   testGetDevice1 = false;
   }
   
   if (myDevicePtrFail == NULL)
   {
	   testGetDevice2 = true;
   }
   else
   {
	   testGetDevice2 = false;
   }

   
   //CPPUNIT_ASSERT(myDevicePtrSuccessful != NULL); // condition for pass: a successful 'Get' doesn't return a NULL pointer
   //CPPUNIT_ASSERT(myDevicePtrFail == NULL); // condition for pass: a failed GetDeviceByMac returns a NULL pointer
}

///////////////////////////////////////////////////////////
//////////////////// TEST GET DEVICE  /////////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
///////////////// TEST GET DEVICE BY NAME /////////////////
///////////////////////////////////////////////////////////

bool testGetDevicebyName()
{
	char OriginalName[20];

	//Set up
	CBgaNetSystem testSystem(eAny);
	CBgaDevice* myDevicePtrSuccessful = NULL; // check a case of a successful find
	CBgaDevice* myDevicePtrFail = (CBgaDevice*)0x69696969; // check an example of an unsuccessful Get

	//Process
	myDevicePtrSuccessful = testSystem.GetDevice(0);

	if(myDevicePtrSuccessful != NULL)
	{
		testGetDevicebyName1 = true;
	}
	else
	{
		cout << "Connect a device!" << endl;
		testGetDevicebyName1 = false;
		return false;
	}

   //CPPUNIT_ASSERT_MESSAGE("Connect a device!", myDevicePtrSuccessful != NULL);

   myDevicePtrSuccessful->GetNetworkInfo()->GetName(OriginalName, sizeof(OriginalName));
   myDevicePtrSuccessful = NULL;
   
   if (myDevicePtrSuccessful == NULL)
   {
	   testGetDevicebyName2 = true;
   }
   else
   {
	   testGetDevicebyName2 = false;
   }
   //CPPUNIT_ASSERT(myDevicePtrSuccessful == NULL);
   myDevicePtrSuccessful = testSystem.GetDeviceByName(OriginalName); // works only on Jerry's Bouboule
   myDevicePtrFail = testSystem.GetDeviceByName("MoThErFuCkEr");

   //Check

   if (myDevicePtrSuccessful != NULL)
   {
	   testGetDevicebyName3 = true;
   }
   else
   {
	   testGetDevicebyName3 = false;
   }

   if (myDevicePtrFail == NULL)
   {
	   testGetDevicebyName4 = true;
   }
   else
   {
	   testGetDevicebyName4 = false;
   }

   //CPPUNIT_ASSERT(myDevicePtrSuccessful != NULL); // condition for pass: a successful 'Get' doesn't return a NULL pointer
   //CPPUNIT_ASSERT(myDevicePtrFail == NULL); // condition for pass: a failed GetDeviceByMac returns a NULL pointer
return true;
}

///////////////////////////////////////////////////////////
///////////////// TEST GET DEVICE BY NAME /////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
////////////////// TEST GET DEVICE BY IP //////////////////
///////////////////////////////////////////////////////////

bool testGetDeviceByIp()
{
	//Set up
	CBgaNetSystem testSystem(eAny);
	CBgaDevice* myDevicePtrSuccessful = NULL; // check a case of a successful find
	CBgaDevice* myDevicePtrFail = (CBgaDevice*)0x69696969; // check an example of an unsuccessful Get

	//Process
	//Since we tested GetDevice right before we can use it to know the ip of the device.
	myDevicePtrSuccessful = testSystem.GetDevice(0);

	if(myDevicePtrSuccessful != NULL)
	{
		testGetDevicebyIp1 = true;
	}
	else
	{
		cout << "Connect a device!" << endl;
		testGetDevicebyIp1 = false;
		return false;
	}

	//CPPUNIT_ASSERT_MESSAGE("Connect a device!", myDevicePtrSuccessful != NULL);
	long IpAddress = myDevicePtrSuccessful->GetNetworkInfo()->GetIpAddress();

	myDevicePtrSuccessful = NULL;
	myDevicePtrSuccessful = testSystem.GetDeviceByIp(IpAddress); // works only on Jerry's Bouboule
	myDevicePtrFail = testSystem.GetDeviceByIp(IpAddress-1);

	//Check
   
	if (myDevicePtrSuccessful != NULL)
	{
		testGetDevicebyIp2 = true;
	}
	else
	{
		testGetDevicebyIp2 = false;
	}
   
	if (myDevicePtrFail == NULL)
	{
		testGetDevicebyIp3 = true;
	}
	else
	{
		testGetDevicebyIp3 = false;
	}

   //CPPUNIT_ASSERT(myDevicePtrSuccessful != NULL); // condition for pass: a successful 'Get' doesn't return a NULL pointer
   //CPPUNIT_ASSERT(myDevicePtrFail == NULL); // condition for pass: a failed GetDeviceByMac returns a NULL pointer
return true;
}

///////////////////////////////////////////////////////////
////////////////// TEST GET DEVICE BY IP //////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
///////////////// TEST GET DEVICE BY MAC //////////////////
///////////////////////////////////////////////////////////

bool testGetDevicebyMac()
{   
   //Set up
   CBgaNetSystem testSystem(eAny);
   CBgaDevice* myDevicePtrSuccessful = NULL; // check a case of a successful Get
   CBgaDevice* myDevicePtrFail = (CBgaDevice*)0x69696969; // check an example of an unsuccessful Get

   //Process
   myDevicePtrSuccessful = testSystem.GetDevice(0);

	if(myDevicePtrSuccessful != NULL)
	{
		testGetDevicebyMac1 = true;
	}
	else
	{
		cout << "Connect a device!" << endl;
		testGetDevicebyMac1 = false;
		return false;
	}
   //CPPUNIT_ASSERT_MESSAGE("Connect a device!", myDevicePtrSuccessful != NULL);

   INT_64 MacToSearchFor = myDevicePtrSuccessful->GetNetworkInfo()->GetMacAddress();
   
   if (MacToSearchFor != 0)
   {
	   testGetDevicebyMac2 = true;
   }
   else
   {
	   testGetDevicebyMac2 = false;
   }
   
   //CPPUNIT_ASSERT(MacToSearchFor != 0);
   myDevicePtrSuccessful = NULL;

   if (myDevicePtrSuccessful == NULL)
   {
	   testGetDevicebyMac3 = true;
   }
   else
   {
	   testGetDevicebyMac3 = false;
   }
   
   //CPPUNIT_ASSERT(myDevicePtrSuccessful == NULL);
   myDevicePtrSuccessful = testSystem.GetDeviceByMac(MacToSearchFor);

	if(myDevicePtrSuccessful != NULL)
	{
		testGetDevicebyMac4 = true;
	}
	else
	{
		cout << "Connect a device!" << endl;
		testGetDevicebyMac4 = false;
		return false;
	}

   //CPPUNIT_ASSERT_MESSAGE("Connect a device!", myDevicePtrSuccessful != NULL);
   myDevicePtrFail = testSystem.GetDeviceByMac(MacToSearchFor+1);

   //Check

   if (myDevicePtrSuccessful != NULL)
   {
	   testGetDevicebyMac5 = true;
   }
   else
   {
	   testGetDevicebyMac5 = false;

   }
  
   if (myDevicePtrFail == NULL)
   {
	   testGetDevicebyMac6 = true;
   }
   else
   {
	   testGetDevicebyMac6 = false;

   }

   //CPPUNIT_ASSERT(myDevicePtrSuccessful != NULL); // condition for pass: a successful 'Get' doesn't return a NULL pointer
   //CPPUNIT_ASSERT(myDevicePtrFail == NULL); // condition for pass: a failed GetDeviceByMac returns a NULL pointer
return true;
}

///////////////////////////////////////////////////////////
///////////////// TEST GET DEVICE BY MAC //////////////////
///////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////
/////////////////////// MAIN FUNCTION /////////////////////
///////////////////////////////////////////////////////////

int main(int argc, char* argv[]) 
{	
	ofstream File,file;

	char dateStr [9];
    char timeStr [9];
	int n = 1;

	if (argc < 2)
	{
      printf("Usage: Testcase.exe test ...\n");
        return 0;
	}
		
	if(strcmp(argv[1],"test") == 0)
	{	
		File.open("CBgaNetSystemTestCases.ini",ofstream::app);
		File<<"\n[TESTCASES]\n";
		//printf("TESTFILENAME: test1.exe" "\n");
		//File<<"filename="<<argv[0]<<endl;
		_strdate(dateStr);
		//printf("DATE: %s \n", dateStr);
		_strtime( timeStr );
		File<<"dt= "<<dateStr<<" "<<timeStr<<endl;
		//printf("TIME %s \n", timeStr);
		File<<"tc=7"<<endl; //number of test cases in exe file

		for(int i=2; i<argc; i++)
		{	
			//first argument

			///////////////////////////////////
			//testing testConstructor() function
			///////////////////////////////////
			if(strcmp(argv[i],"testConstructor") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t1descr=testConstructor" << endl;
				File<<"t1dn=2"<< endl; //number of "if" statements in test
				cout<<"Test Case: testConstructor"<<endl;

				
				setUp();
/*
				testConstructor();

				if (testConstructor()==false)
				{
					File<<"err=true"<<endl;
					return 1;
				}
*/
				if(testConstructor1 == true)
				{					
					File<<"t1d1descr=pAutoDevice != NULL" << endl;
					File<<"t1d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t1d1descr=pAutoDevice != NULL" << endl;
					File<<"t1d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}

				if(testConstructor2 == true)
				{
					File<<"t1d2descr=pNonAutoDevice == NULL" << endl;
					File<<"t1d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t1d2descr=pNonAutoDevice == NULL" << endl;
					File<<"t1d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}

				if(testConstructor1 == true && testConstructor2 == true)
				{
					File<<"t1result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}
								
				if(testConstructor1 == false || testConstructor2 == false)
				{
					File<<"t1result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}

				
			//second argument

			///////////////////////////////////
			//testing testDiscoverDevices() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testDiscoverDevices") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t2descr=testDiscoverDevices" << endl;
				File<<"t2dn=1"<< endl; //number of "if" statements in test
				cout<<"Test Case: testDiscoverDevices"<<endl;
				
				setUp();
				/*
				testDiscoverDevices();

				if (testDiscoverDevice()==false)
				{
					File<<"err=true"<<endl;
					return 1;
				}
*/
				if(testDiscoverDevices1 == true)
				{					
					File<<"t2d1descr=pNonAutoDevice != NULL" << endl;
					File<<"t2d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t2d1descr=pNonAutoDevice != NULL" << endl;
					File<<"t2d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}

				if(testDiscoverDevices1 == true)
				{
					File<<"t2result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testDiscoverDevices1 == false)
				{
					File<<"t2result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}


			
			//third argument

			///////////////////////////////////
			//testing testGetNumberOfDevices() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testGetNumberofDevices") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t3descr=testGetNumberofDevices" << endl;
				File<<"t3dn=2"<< endl; //number of "if" statements in test
				cout<<"Test Case: testGetNumberofDevices"<<endl;
				
				setUp();
				/*
				testGetNumberofDevices();

				if (testGetNumberofDevice()==false)
				{
					File<<"err=true"<<endl;
					return 1;
				}
*/
				if(testGetNumberofDevices1 == true)
				{					
					File<<"t3d1descr=DeviceCountOne == 1" << endl;
					File<<"t3d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t3d1descr=DeviceCountOne == 1" << endl;
					File<<"t3d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}
				
				if(testGetNumberofDevices2 == true)
				{					
					File<<"t3d2descr=DeviceCountZero == 0" << endl;
					File<<"t3d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t3d2descr=DeviceCountZero == 0" << endl;
					File<<"t3d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}

				if(testGetNumberofDevices1 == true || testGetNumberofDevices2 == true)
				{
					File<<"t3result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testGetNumberofDevices1 == false || testGetNumberofDevices2 == false)
				{
					File<<"t3result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}
			//fourth argument

			///////////////////////////////////
			//testing testGetDevice() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testGetDevice") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t4descr=testGetDevice" << endl;
				File<<"t4dn=2"<< endl; //number of "if" statements in test
				cout<<"Test Case: testGetDevice"<<endl;
				
				setUp();
				/*
				testGetDevice();

				if (testDevice()==false)
				{
					File<<"err=true"<<endl;
					return 1;
				}
*/
				if(testGetDevice1 == true)
				{					
					File<<"t4d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t4d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t4d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t4d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}
				
				if(testGetDevice2 == true)
				{					
					File<<"t4d2descr=myDevicePtrFail == NULL" << endl;
					File<<"t4d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t4d2descr=myDevicePtrFail == NULL" << endl;
					File<<"t4d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}

				if(testGetDevice1 == true && testGetDevice2 == true)
				{
					File<<"t4result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testGetDevice1 == false || testGetDevice2 == false)
				{
					File<<"t4result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}
			//fifth argument

			///////////////////////////////////
			//testing testGetDevicebyName() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testGetDevicebyName") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t5descr=testGetDevicebyName" << endl;
				File<<"t5dn=4"<< endl; //number of "if" statements in test
				cout<<"Test Case: testGetDevicebyName"<<endl;
				
				setUp();

				//testGetDevicebyName();

				if (testGetDevicebyName()==false)
				{
					File<<"err=true"<<endl;
					break;
				}

				if(testGetDevicebyName1 == true)
				{					
					File<<"t5d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t5d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t5d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t5d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}
				
				if(testGetDevicebyName2 == true)
				{					
					File<<"t5d2descr=myDevicePtrpass == NULL" << endl;
					File<<"t5d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t5d2descr=myDevicePtrpass == NULL" << endl;
					File<<"t5d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}
				if(testGetDevicebyName3 == true)
				{					
					File<<"t5d3descr=myDevicePtrpass != NULL" << endl;
					File<<"t5d3=pass" << endl;
					cout << "Test #3 = pass " << endl;
				}
			
				else
				{
					File<<"t5d3descr=myDevicePtrpass != NULL" << endl;
					File<<"t5d3=fail" << endl;
					cout << "Test #3 = fail " << endl;
				}

				if(testGetDevicebyName4 == true)
				{					
					File<<"t5d4descr=myDevicePtrFail == NULL" << endl;
					File<<"t5d4=pass" << endl;
					cout << "Test #4 = pass " << endl;
				}
			
				else
				{
					File<<"t5d4descr=myDevicePtrFail == NULL" << endl;
					File<<"t5d4=fail" << endl;
					cout << "Test #4 = fail " << endl;
				}

				if(testGetDevicebyName1 == true && testGetDevicebyName2 == true && testGetDevicebyName3 == true && testGetDevicebyName4 == true)
				{
					File<<"t5result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testGetDevicebyName1 == false || testGetDevicebyName2 == false || testGetDevicebyName3 == false || testGetDevicebyName4 == false)
				{
					File<<"t5result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}
			//sixth argument

			///////////////////////////////////
			//testing testGetDevicebyIp() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testGetDevicebyIp") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t6descr=testGetDevicebyIp" << endl;
				File<<"t6dn=3"<< endl; //number of "if" statements in test
				cout<<"Test Case: testGetDevicebyIp"<<endl;
				
				setUp();
				//testGetDevicebyIp();

				if(testGetDeviceByIp()==false)
				{
					File<<"err=true"<<endl;
					break;
				}

				if(testGetDevicebyIp1 == true)
				{					
					File<<"t6d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t6d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t6d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t6d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}
				
				if(testGetDevicebyIp2 == true)
				{					
					File<<"t6d2descr=myDevicePtrpass != NULL" << endl;
					File<<"t6d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t6d2descr=myDevicePtrpass != NULL" << endl;
					File<<"t6d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}
				if(testGetDevicebyIp3 == true)
				{					
					File<<"t6d3descr=myDevicePtrFail == NULL" << endl;
					File<<"t6d3=pass" << endl;
					cout << "Test #3 = pass " << endl;
				}
			
				else
				{
					File<<"t6d3descr=myDevicePtrFail == NULL" << endl;
					File<<"t6d3=fail" << endl;
					cout << "Test #3 = fail " << endl;
				}

				if(testGetDevicebyIp1 == true && testGetDevicebyIp2 == true && testGetDevicebyIp3 == true)
				{
					File<<"t6result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testGetDevicebyIp1 == false || testGetDevicebyIp2 == false || testGetDevicebyIp3 == false)
				{
					File<<"t6result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}


			//seventh argument

			///////////////////////////////////
			//testing testGetDevicebyMac() function
			///////////////////////////////////
			else if(strcmp(argv[i],"testGetDevicebyMac") == 0)
			{	
				File<<"[Test " << n << "]" << endl;
				File<<"t7descr=testGetDevicebyMac" << endl;
				File<<"t7dn=6"<< endl; //number of "if" statements in test
				cout<<"Test Case: testGetDevicebyMac"<<endl;
				
				setUp();
				//testGetDevicebyMac();

				if(testGetDevicebyMac()==false)
				{
					File<<"err=true"<<endl;
					break;
				}

				if(testGetDevicebyMac1 == true)
				{					
					File<<"t7d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d1=pass" << endl;
					cout << "Test #1 = pass " << endl;
				}
			
				else
				{
					File<<"t7d1descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d1=fail" << endl;
					cout << "Test #1 = fail " << endl;
				}
				
				if(testGetDevicebyMac2 == true)
				{					
					File<<"t7d2descr=MacToSearchFor != 0" << endl;
					File<<"t7d2=pass" << endl;
					cout << "Test #2 = pass " << endl;
				}
			
				else
				{
					File<<"t7d2descr=MacToSearchFor != 0" << endl;
					File<<"t7d2=fail" << endl;
					cout << "Test #2 = fail " << endl;
				}

				if(testGetDevicebyMac3 == true)
				{					
					File<<"t7d3descr=myDevicePtrpass == NULL" << endl;
					File<<"t7d3=pass" << endl;
					cout << "Test #3 = pass " << endl;
				}
			
				else
				{
					File<<"t7d3descr=myDevicePtrpass == NULL" << endl;
					File<<"t7d3=fail" << endl;
					cout << "Test #3 = fail " << endl;
				}

				if(testGetDevicebyMac4 == true)
				{					
					File<<"t7d4descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d4=pass" << endl;
					cout << "Test #4 = pass " << endl;
				}
			
				else
				{
					File<<"t7d4descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d4=fail" << endl;
					cout << "Test #4 = fail " << endl;
				}

				if(testGetDevicebyMac5 == true)
				{					
					File<<"t7d5descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d5=pass" << endl;
					cout << "Test #5 = pass " << endl;
				}
			
				else
				{
					File<<"t7d5descr=myDevicePtrpass != NULL" << endl;
					File<<"t7d5=fail" << endl;
					cout << "Test #5 = fail " << endl;
				}

				if(testGetDevicebyMac6 == true)
				{					
					File<<"t7d6descr=myDevicePtrFail == NULL" << endl;
					File<<"t7d6=pass" << endl;
					cout << "Test #6 = pass " << endl;
				}
			
				else
				{
					File<<"t7d6descr=myDevicePtrFail == NULL" << endl;
					File<<"t7d6=fail" << endl;
					cout << "Test #6 = fail " << endl;
				}

				if(testGetDevicebyMac1 == true && testGetDevicebyMac2 == true && testGetDevicebyMac3 == true && testGetDevicebyMac4 == true && testGetDevicebyMac5 == true && testGetDevicebyMac6 == true)
				{
					File<<"t7result=pass" << endl;
					cout << "Overall Test Case = pass "<< endl;
				}

				if(testGetDevicebyMac1 == false || testGetDevicebyMac2 == false || testGetDevicebyMac3 == false || testGetDevicebyMac4 == false || testGetDevicebyMac5 == false || testGetDevicebyMac6 == false)
				{
					File<<"t7result=fail" << endl;
					cout << "Overall Test Case = fail "<< endl;
				}

				tearDown();
				n++;
			}
			
		}
	
		File.close();
	}

else if(strcmp(argv[1],"list") == 0)
	{	
		File.open("CBgaNetSystemTestCases.ini");
			
		File<<"[list]\n";
		File<<"count=7"<<endl; //number of test cases in exe file

		File<<"Test1=testConstructor" << endl;
		File<<"Test2=testDiscoverDevices" << endl;
		File<<"Test3=testGetNumberofDevices" << endl;
		File<<"Test4=testGetDevice" << endl;
		File<<"Test5=testGetDevicebyName" << endl;
		File<<"Test6=testGetDevicebyIp" << endl;
		File<<"Test7=testGetDevicebyMac" << endl;
		
		cout << "Here are a list of Tests available: \n1) testConstructor\n2) testDiscoverDevices\n3) testGetNumberofDevices\n4) testGetDevice\n5) testGetDevicebyName\n6) testGetDevicebyIp\n7) testGetDevicebyMac" << endl;

		File.close();
	}

	return 0;
}

///////////////////////////////////////////////////////////
/////////////////////// MAIN FUNCTION /////////////////////
///////////////////////////////////////////////////////////


